#!/bin/bash
# Setup datasources and mysql connection pools for all projects in glassfish
# Be sure to set glassfishHome in your shell environment

# Capacity
$glassfishHome/bin/asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=root:password=root:databaseName=capacity:serverName=localhost:portNumber=3306 MySQLCapacity
$glassfishHome/bin/asadmin create-jdbc-resource --connectionpoolid MySQLCapacity jdbc/capacityDS

# GUI
$glassfishHome/bin/asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=root:password=root:databaseName=gui:serverName=localhost:portNumber=3306 MySQLGui
$glassfishHome/bin/asadmin create-jdbc-resource --connectionpoolid MySQLGui jdbc/guiDS

# Offer
$glassfishHome/bin/asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=root:password=root:databaseName=offer:serverName=localhost:portNumber=3306 MySQLOffer
$glassfishHome/bin/asadmin create-jdbc-resource --connectionpoolid MySQLOffer jdbc/offerDS

# Product
$glassfishHome/bin/asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=root:password=root:databaseName=product:serverName=localhost:portNumber=3306 MySQLProduct
$glassfishHome/bin/asadmin create-jdbc-resource --connectionpoolid MySQLProduct jdbc/productDS

# Idmap
$glassfishHome/bin/asadmin create-jdbc-connection-pool --restype javax.sql.DataSource --datasourceclassname com.mysql.jdbc.jdbc2.optional.MysqlDataSource --property user=root:password=root:databaseName=idmap:serverName=localhost:portNumber=3306 MySQLIdmap
$glassfishHome/bin/asadmin create-jdbc-resource --connectionpoolid MySQLIdmap jdbc/idmapDS
